#include"sams.h"
#include"struct.h"
#include"dao.h"
#include"tools.h"
#include"admin.h"
#include"teacher.h"
List* tch_list;
List* stu_list;

void show_menu(void)
{
	system("clear");
	puts("****欢迎使用学生信息管理系统*****");
	puts("1、管理员登录");
	puts("2、教师登录");
	puts("3、学生登录");
	puts("4、退出系统");

}

void sams_init(void)
{
	tch_list = create_list();
	stu_list = create_list();
	load_data(tch_list,"./data/teacher.dat",sizeof(Teacher));
	load_data(stu_list,"./data/student.dat",sizeof(Student));
}

void sams_start(void)
{
	for(;;)
	{
		show_menu();
		switch(get_cmd('1','4'))
		{
			case '1':admin_login();
			break;
			case '2':tea_login(); 
			break;
			case '3'://stu_login(); 
			break;
			case '4':sams_exit(); 
			return;
		}
	}
}

void sams_exit(void)
{
	save_data(tch_list,"./data/teacher.dat",sizeof(Teacher));
	destory_list(tch_list);
	save_data(stu_list,"./data/student.dat",sizeof(Student));
	destory_list(stu_list);

}


